package com.javaeedev.junit;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.Map;

public class RemoteAuthService extends UnicastRemoteObject implements AuthService {

    private Map<String, String> users = new HashMap<String, String>();

    public RemoteAuthService() throws RemoteException {
        users.put("test", "test");
        users.put("admin", "admin");
        users.put("guest", "x");
    }

    public void authenticate(String username, String password) throws AuthenticateException, RemoteException {
        if(!password.equals(users.get(username)))
            throw new AuthenticateException();
    }

}
